namespace QMVnSoft.ReportForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormKCD20Viewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblMa_Sp;
        private LabelControl lblMa_Sp_Me;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private TextSearch txtMa_Sp;
        private TextSearch txtMa_Sp_Me;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Sp;
        private TextControl txtTen_Sp_Me;

        public FormKCD20Viewer()
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormKCD20Viewer));
            this.txtTen_Sp = new QMVnSoft.Controls.TextControl();
            this.txtMa_Sp = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Sp = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Sp_Me = new QMVnSoft.Controls.TextControl();
            this.txtMa_Sp_Me = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Sp_Me = new QMVnSoft.Controls.LabelControl();
            this.txtNgay_Ct2 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct2 = new QMVnSoft.Controls.LabelControl();
            this.txtNgay_Ct1 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct1 = new QMVnSoft.Controls.LabelControl();
            this.rptContainer.Panel1.SuspendLayout();
            this.rptContainer.SuspendLayout();
            this.SuspendLayout();
            // 
            // rptContainer
            // 
            // 
            // rptContainer.Panel1
            // 
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Sp_Me);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Sp_Me);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Sp_Me);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Sp);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Sp);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Sp);
            this.rptContainer.SplitterDistance = 67;
            // 
            // txtTen_Sp
            // 
            this.txtTen_Sp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Sp.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Sp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Sp.CheckTextSearched = false;
            this.txtTen_Sp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Enabled = false;
            this.txtTen_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Sp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Location = new System.Drawing.Point(214, 28);
            this.txtTen_Sp.Name = "txtTen_Sp";
            this.txtTen_Sp.OldValue = null;
            this.txtTen_Sp.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Sp.TabIndex = 90;
            this.txtTen_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Sp.Value = ((object)(resources.GetObject("txtTen_Sp.Value")));
            // 
            // txtMa_Sp
            // 
            this.txtMa_Sp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Sp.CheckTextSearched = false;
            this.txtMa_Sp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Sp.EmptyIsValid = true;
            this.txtMa_Sp.FieldDisplay = "Ten_Sp";
            this.txtMa_Sp.FirstFilter = "Loai_Sp = \'C\'";
            this.txtMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Sp.FoundIsValid = true;
            this.txtMa_Sp.Location = new System.Drawing.Point(108, 24);
            this.txtMa_Sp.MaxLength = 32;
            this.txtMa_Sp.Name = "txtMa_Sp";
            this.txtMa_Sp.OldValue = null;
            this.txtMa_Sp.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Sp.TabIndex = 1;
            this.txtMa_Sp.TableName = "DMSP";
            this.txtMa_Sp.TextDisplay = this.txtTen_Sp;
            this.txtMa_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Sp.Value = ((object)(resources.GetObject("txtMa_Sp.Value")));
            // 
            // lblMa_Sp
            // 
            this.lblMa_Sp.AutoSize = true;
            this.lblMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Sp.Location = new System.Drawing.Point(12, 27);
            this.lblMa_Sp.Name = "lblMa_Sp";
            this.lblMa_Sp.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Sp.TabIndex = 89;
            this.lblMa_Sp.Text = "Sản phẩm";
            // 
            // txtTen_Sp_Me
            // 
            this.txtTen_Sp_Me.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Sp_Me.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Sp_Me.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Sp_Me.CheckTextSearched = false;
            this.txtTen_Sp_Me.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp_Me.Enabled = false;
            this.txtTen_Sp_Me.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Sp_Me.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp_Me.Location = new System.Drawing.Point(214, 7);
            this.txtTen_Sp_Me.Name = "txtTen_Sp_Me";
            this.txtTen_Sp_Me.OldValue = null;
            this.txtTen_Sp_Me.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Sp_Me.TabIndex = 95;
            this.txtTen_Sp_Me.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Sp_Me.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Sp_Me.Value = ((object)(resources.GetObject("txtTen_Sp_Me.Value")));
            // 
            // txtMa_Sp_Me
            // 
            this.txtMa_Sp_Me.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Sp_Me.CheckTextSearched = false;
            this.txtMa_Sp_Me.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Sp_Me.EmptyIsValid = true;
            this.txtMa_Sp_Me.FieldDisplay = "Ten_Sp";
            this.txtMa_Sp_Me.FirstFilter = "Loai_Sp = \'K\'";
            this.txtMa_Sp_Me.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Sp_Me.FoundIsValid = true;
            this.txtMa_Sp_Me.Location = new System.Drawing.Point(108, 3);
            this.txtMa_Sp_Me.MaxLength = 32;
            this.txtMa_Sp_Me.Name = "txtMa_Sp_Me";
            this.txtMa_Sp_Me.OldValue = null;
            this.txtMa_Sp_Me.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Sp_Me.TabIndex = 0;
            this.txtMa_Sp_Me.TableName = "DMSP";
            this.txtMa_Sp_Me.TextDisplay = this.txtTen_Sp_Me;
            this.txtMa_Sp_Me.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Sp_Me.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Sp_Me.Value = ((object)(resources.GetObject("txtMa_Sp_Me.Value")));
            // 
            // lblMa_Sp_Me
            // 
            this.lblMa_Sp_Me.AutoSize = true;
            this.lblMa_Sp_Me.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Sp_Me.Location = new System.Drawing.Point(12, 6);
            this.lblMa_Sp_Me.Name = "lblMa_Sp_Me";
            this.lblMa_Sp_Me.Size = new System.Drawing.Size(59, 14);
            this.lblMa_Sp_Me.TabIndex = 94;
            this.lblMa_Sp_Me.Text = "Công đoạn";
            // 
            // txtNgay_Ct2
            // 
            this.txtNgay_Ct2.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct2.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new System.Drawing.Point(316, 45);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 6;
            this.txtNgay_Ct2.Value = ((object)(resources.GetObject("txtNgay_Ct2.Value")));
            // 
            // lblNgay_Ct2
            // 
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct2.Location = new System.Drawing.Point(256, 48);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new System.Drawing.Size(54, 14);
            this.lblNgay_Ct2.TabIndex = 97;
            this.lblNgay_Ct2.Text = "Đến ngày";
            // 
            // txtNgay_Ct1
            // 
            this.txtNgay_Ct1.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new System.Drawing.Point(108, 45);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 5;
            this.txtNgay_Ct1.Value = ((object)(resources.GetObject("txtNgay_Ct1.Value")));
            // 
            // lblNgay_Ct1
            // 
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct1.Location = new System.Drawing.Point(12, 48);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new System.Drawing.Size(47, 14);
            this.lblNgay_Ct1.TabIndex = 98;
            this.lblNgay_Ct1.Text = "Từ ngày";
            // 
            // FormKCD20Viewer
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.CheckDetailMost = true;
            this.ClientSize = new System.Drawing.Size(794, 539);
            this.Name = "FormKCD20Viewer";
            this.rptContainer.Panel1.ResumeLayout(false);
            this.rptContainer.Panel1.PerformLayout();
            this.rptContainer.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnGenerateColumns()
        {
            object[][] objArray = new object[11][];
            object[] objArray2 = new object[4];
            objArray2[0] = "Ma_Sp";
            objArray2[1] = "Sản phẩm";
            objArray2[2] = "C";
            objArray[0] = objArray2;
            object[] objArray3 = new object[4];
            objArray3[0] = "Ten_Sp";
            objArray3[1] = "Tên sản phẩm";
            objArray3[2] = "C";
            objArray[1] = objArray3;
            object[] objArray4 = new object[4];
            objArray4[0] = "Dvt";
            objArray4[1] = "Đơn vị tính";
            objArray4[2] = "C";
            objArray[2] = objArray4;
            objArray[3] = new object[] { "Du_Dau", "Dư đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
            objArray[4] = new object[] { "Ps_No", "Phát sinh", "N", AppInstance.TextNumericFormat.LocalAmount };
            objArray[5] = new object[] { "So_LuongHT", "Số lượng hoàn thành", "N", AppInstance.TextNumericFormat.Quantity };
            objArray[6] = new object[] { "Gia", "Đơn giá", "N", AppInstance.TextNumericFormat.LocalPrice };
            objArray[7] = new object[] { "Ps_Co", "Giá thành", "N", AppInstance.TextNumericFormat.LocalAmount };
            objArray[8] = new object[] { "So_LuongDD", "Số lượng dở dang", "N", AppInstance.TextNumericFormat.Quantity };
            objArray[9] = new object[] { "Ty_Le_Ht", "%HT", "N", AppInstance.TextNumericFormat.Percent };
            objArray[10] = new object[] { "Du_Cuoi", "Dư cuối", "N", AppInstance.TextNumericFormat.LocalPrice };
            base.LocalColNames = objArray;
            base.OnGenerateColumns();
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            base.LocalTable = new ReportDataAccess().KCD20_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtMa_Sp_Me.Value, this.txtMa_Sp.Value);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (!string.IsNullOrEmpty(this.txtMa_Sp_Me.Value.ToString()))
            {
                base.StimulReport["CongDoan"] = string.Concat(new object[] { "Công đoạn: ", this.txtMa_Sp_Me.Value, " - ", this.txtTen_Sp_Me.Value });
            }
            if (!string.IsNullOrEmpty(this.txtMa_Sp.Value.ToString()))
            {
                base.StimulReport["SanPham"] = string.Concat(new object[] { "Sản phẩm: ", this.txtMa_Sp.Value, " - ", this.txtTen_Sp.Value });
            }
        }
    }
}

